﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class UserControls_nguoidung : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        

            string ID_NGUOIDUNG = (string)Session["ID_NGUOIDUNG"];
            if (ID_NGUOIDUNG == null)
            {
                Response.Redirect("dangnhap.aspx");

            }
            else
            {
                DataTable dt = CatalogAccess.GetNguoiDung(ID_NGUOIDUNG);

              
                th_tennd.Text = dt.Rows[0]["TENND"].ToString();
                th_diachi.Text = dt.Rows[0]["DIACHI"].ToString();
                th_dienthoai.Text = dt.Rows[0]["DIENTHOAI"].ToString();
                th_matkhau.Text = dt.Rows[0]["MATKHAU"].ToString();
                th_email.Text = dt.Rows[0]["EMAIL"].ToString();
            }
        
                
      
         

    }
    protected void but_capnhat_Click(object sender, EventArgs e)
    {
       
            int tam = 0;
            string diachi = "";
            string dienthoai = "";
            string email = "";
            string matkhau = "";
            string tennd = "";
            string ID_NGUOIDUNG = (string)Session["ID_NGUOIDUNG"];
            if (th_diachi.Text == "")
            {
                Lbldc.Visible = true;
                tam = 1;
            }
            else
            {
                Lbldc.Visible = false;
                tam = 0;
                diachi = th_diachi.Text;
            }

            if (th_dienthoai.Text == "")
            {
                lbldt.Visible = true;
                tam = 1;
            }
            else
            {
                lbldt.Visible = false;
                tam = 0;
                dienthoai = th_dienthoai.Text;
            }

            if (th_email.Text == "")
            {
                lblemail.Visible = true;
                tam = 1;
            }
            else
            {
                lblemail.Visible = false;
                tam = 0;
                email = th_email.Text;
            }

            if (th_matkhau.Text == "")
            {
                lblmk.Visible = true;
                tam = 1;
            }
            else
            {
                lblmk.Visible = false;
                tam = 0;
                matkhau = th_matkhau.Text;
            }

            if (th_tennd.Text == "")
            {
                Lbltennd.Visible = true;
                tam = 1;
            }
            else
            {
                Lbltennd.Visible = false;
                tam = 0;
                tennd = th_tennd.Text;
            }
            if (tam == 0)
            {
                CatalogAccess.GetCapNhatND(ID_NGUOIDUNG, diachi, dienthoai, email, matkhau, tennd);
                Response.Redirect("default.aspx");
            }
       

    }
    protected void but_thoat_Click(object sender, EventArgs e)
    {
        Response.Redirect("default.aspx");
    }
}
